import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class day_05_IO_5 {
    public static void main(String[] args) throws IOException {
        //文件拷贝改写

        //创建文件读取对象
        FileInputStream fileInputStream = new FileInputStream("1.jpg");
        //创建文件写出对象
        FileOutputStream fileOutputStream = new FileOutputStream("2.jpg");
        
        //记录拷贝文件前的时间
        long startTime = System.currentTimeMillis();

        //拷贝
        int len;
        byte[] bytes = new byte[1024 * 1024 * 5];
        while ((len = fileInputStream.read(bytes)) != -1) {
            fileOutputStream.write(bytes, 0, len);
        }

        //文件拷贝耗时
        System.out.println(System.currentTimeMillis() - startTime + " ms");

        //释放资源
        fileOutputStream.close();
        fileInputStream.close();
    }
}
